package com.seabook.store.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ServiceLocator {
   private static ApplicationContext context = null;
   
   
   public static Object getBean(String beanName){
       if(null == context){
           context = initContext();
       }
       return context.getBean(beanName);
   }
   
   private static ApplicationContext initContext(){
       context = new ClassPathXmlApplicationContext(new String[] {
               "applicationContext.xml"});
       return context;
   }
   
   public static void main(String[] args){
       initContext();
   }
}
